package org.dromara.job.snailjob;

import com.aizuda.snailjob.client.job.core.annotation.JobExecutor;
import com.aizuda.snailjob.client.job.core.dto.JobArgs;
import com.aizuda.snailjob.client.model.ExecuteResult;
import com.aizuda.snailjob.common.core.util.JsonUtil;
import com.aizuda.snailjob.common.log.SnailJobLog;
import org.apache.dubbo.config.annotation.DubboReference;
import org.dromara.tearoom.api.RemoteOrderService;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Component
@JobExecutor(name = "broadcastJobExecute")
public class BroadcastJobExecute {
    @DubboReference
    RemoteOrderService remoteOrderService;


    public ExecuteResult jobExecute(JobArgs jobArgs) {
        remoteOrderService.broadcastTask(LocalDateTime.now());

        SnailJobLog.LOCAL.info("BroadcastJobExecute. jobArgs:{}", JsonUtil.toJsonString(jobArgs));
        SnailJobLog.REMOTE.info("BroadcastJobExecute. jobArgs:{}", JsonUtil.toJsonString(jobArgs));

        return ExecuteResult.success("成功");
    }
}
